<template>
  <div class="main p-20">
    <p class="el-icon-user-solid aboutusTitle">
      {{ currentPage[0] && currentPage[0].title }}
    </p>
    <div class="aboutUs">
      <div class="content" v-for="item in currentPage" :key="item.id">
        <p class="title" style="padding: 15px 0">{{ item.title }}</p>
        <span
          class="article"
          style="text-indent: 2em"
          v-html="item.content"
        ></span>
      </div>
    </div>
  </div>
</template>

<script>
import { getPages } from "@/api/pages.js";
export default {
  data() {
    return {
      currentPage: [],
    };
  },
  watch: {
    $route: {
      immediate: true, // 立即执行
      deep: true, // 深度侦听复杂类型内变化
      handler() {
        this.getCurrentPage(this.$route.params.id);
      },
    },
  },
  created() {
    this.getCurrentPage(this.$route.params.id);
  },
  methods: {
    async getCurrentPage(id) {
      const { data } = await getPages({
        _limit: 3,
        _start: 0,
        title_contains: "",
      });
      this.currentPage = data.filter((item) => item.id == id);
    },
  },
};
</script>

<style lang="less" scoped>
//测试合并
.aboutUs {
  border: 1px solid #ccc;
  .content {
    padding: 20px;
    .title {
      font-weight: 700;
      font-size: 24px;
    }
    .article {
      line-height: 30px;
    }
  }
}
</style>